package androidx.appcompat.widget;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.ViewPropertyAnimator;
import android.view.Window.Callback;
import android.widget.OverScroller;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.view.ViewCompat;
import o.ah$i;
import o.ah.c;
import o.bn;
import o.cj;
import o.ck;
import o.de;
import o.ht;
import o.hu;

@RestrictTo({d.LIBRARY_GROUP})
public class ActionBarOverlayLayout extends ViewGroup implements cj, ht {
    static final int[] ˎ = new int[]{c.ˋ, 16842841};
    private ck ʻ;
    private final Rect ʻॱ;
    private Drawable ʼ;
    private OverScroller ʼॱ;
    private int ʽ;
    private final Rect ʽॱ;
    private final Rect ʾ;
    private a ʿ;
    private final Rect ˈ;
    boolean ˊ;
    private final Runnable ˊˋ;
    private boolean ˊॱ;
    private final Runnable ˊᐝ;
    final AnimatorListenerAdapter ˋ;
    private final hu ˋˊ;
    private boolean ˋॱ;
    ActionBarContainer ˏ;
    private boolean ˏॱ;
    private int ͺ;
    ViewPropertyAnimator ॱ;
    private boolean ॱˊ;
    private int ॱˋ;
    private final Rect ॱˎ;
    private int ॱॱ;
    private final Rect ॱᐝ;
    private ContentFrameLayout ᐝ;
    private final Rect ᐝॱ;

    public static class LayoutParams extends MarginLayoutParams {
        public LayoutParams(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public LayoutParams(int i, int i2) {
            super(i, i2);
        }

        public LayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }
    }

    public interface a {
        void ʻ();

        void ˊ(int i);

        void ˋॱ();

        void ˏॱ();

        void ॱˊ();

        void ॱॱ(boolean z);
    }

    protected /* synthetic */ android.view.ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return ˏ();
    }

    public /* synthetic */ android.view.ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return ˋ(attributeSet);
    }

    public ActionBarOverlayLayout(Context context) {
        this(context, null);
    }

    public ActionBarOverlayLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ʽ = 0;
        this.ᐝॱ = new Rect();
        this.ʻॱ = new Rect();
        this.ॱˎ = new Rect();
        this.ॱᐝ = new Rect();
        this.ʽॱ = new Rect();
        this.ˈ = new Rect();
        this.ʾ = new Rect();
        this.ˋ = new AnimatorListenerAdapter(this) {
            final /* synthetic */ ActionBarOverlayLayout ˊ;

            {
                this.ˊ = r1;
            }

            public void onAnimationEnd(Animator animator) {
                this.ˊ.ॱ = null;
                this.ˊ.ˊ = false;
            }

            public void onAnimationCancel(Animator animator) {
                this.ˊ.ॱ = null;
                this.ˊ.ˊ = false;
            }
        };
        this.ˊᐝ = new Runnable(this) {
            final /* synthetic */ ActionBarOverlayLayout ˎ;

            {
                this.ˎ = r1;
            }

            public void run() {
                this.ˎ.ˋ();
                this.ˎ.ॱ = this.ˎ.ˏ.animate().translationY(0.0f).setListener(this.ˎ.ˋ);
            }
        };
        this.ˊˋ = new Runnable(this) {
            final /* synthetic */ ActionBarOverlayLayout ˏ;

            {
                this.ˏ = r1;
            }

            public void run() {
                this.ˏ.ˋ();
                this.ˏ.ॱ = this.ˏ.ˏ.animate().translationY((float) (-this.ˏ.ˏ.getHeight())).setListener(this.ˏ.ˋ);
            }
        };
        ˏ(context);
        this.ˋˊ = new hu(this);
    }

    private void ˏ(Context context) {
        boolean z = true;
        TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(ˎ);
        this.ॱॱ = obtainStyledAttributes.getDimensionPixelSize(0, 0);
        this.ʼ = obtainStyledAttributes.getDrawable(1);
        setWillNotDraw(this.ʼ == null);
        obtainStyledAttributes.recycle();
        if (context.getApplicationInfo().targetSdkVersion >= 19) {
            z = false;
        }
        this.ˋॱ = z;
        this.ʼॱ = new OverScroller(context);
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        ˋ();
    }

    public void setActionBarVisibilityCallback(a aVar) {
        this.ʿ = aVar;
        if (getWindowToken() != null) {
            this.ʿ.ˊ(this.ʽ);
            if (this.ॱˋ != 0) {
                onWindowSystemUiVisibilityChanged(this.ॱˋ);
                ViewCompat.ᐝॱ(this);
            }
        }
    }

    public void setOverlayMode(boolean z) {
        this.ॱˊ = z;
        boolean z2 = z && getContext().getApplicationInfo().targetSdkVersion < 19;
        this.ˋॱ = z2;
    }

    public boolean ˎ() {
        return this.ॱˊ;
    }

    public void setHasNonEmbeddedTabs(boolean z) {
        this.ˏॱ = z;
    }

    public void setShowingForActionMode(boolean z) {
    }

    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        ˏ(getContext());
        ViewCompat.ᐝॱ(this);
    }

    public void onWindowSystemUiVisibilityChanged(int i) {
        boolean z;
        boolean z2 = true;
        if (VERSION.SDK_INT >= 16) {
            super.onWindowSystemUiVisibilityChanged(i);
        }
        ॱ();
        int i2 = this.ॱˋ ^ i;
        this.ॱˋ = i;
        boolean z3 = (i & 4) == 0;
        if ((i & 256) != 0) {
            z = true;
        } else {
            z = false;
        }
        if (this.ʿ != null) {
            a aVar = this.ʿ;
            if (z) {
                z2 = false;
            }
            aVar.ॱॱ(z2);
            if (z3 || !z) {
                this.ʿ.ʻ();
            } else {
                this.ʿ.ˏॱ();
            }
        }
        if ((i2 & 256) != 0 && this.ʿ != null) {
            ViewCompat.ᐝॱ(this);
        }
    }

    protected void onWindowVisibilityChanged(int i) {
        super.onWindowVisibilityChanged(i);
        this.ʽ = i;
        if (this.ʿ != null) {
            this.ʿ.ˊ(i);
        }
    }

    private boolean ˏ(View view, Rect rect, boolean z, boolean z2, boolean z3, boolean z4) {
        boolean z5 = false;
        LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
        if (z && layoutParams.leftMargin != rect.left) {
            layoutParams.leftMargin = rect.left;
            z5 = true;
        }
        if (z2 && layoutParams.topMargin != rect.top) {
            layoutParams.topMargin = rect.top;
            z5 = true;
        }
        if (z4 && layoutParams.rightMargin != rect.right) {
            layoutParams.rightMargin = rect.right;
            z5 = true;
        }
        if (!z3 || layoutParams.bottomMargin == rect.bottom) {
            return z5;
        }
        layoutParams.bottomMargin = rect.bottom;
        return true;
    }

    protected boolean fitSystemWindows(Rect rect) {
        boolean ˏ;
        ॱ();
        if ((ViewCompat.ʻॱ(this) & 256) != 0) {
            ˏ = ˏ(this.ˏ, rect, true, true, false, true);
            this.ॱᐝ.set(rect);
            de.ˋ(this, this.ॱᐝ, this.ᐝॱ);
        } else {
            ˏ = ˏ(this.ˏ, rect, true, true, false, true);
            this.ॱᐝ.set(rect);
            de.ˋ(this, this.ॱᐝ, this.ᐝॱ);
        }
        if (!this.ʽॱ.equals(this.ॱᐝ)) {
            this.ʽॱ.set(this.ॱᐝ);
            ˏ = true;
        }
        if (!this.ʻॱ.equals(this.ᐝॱ)) {
            this.ʻॱ.set(this.ᐝॱ);
            ˏ = true;
        }
        if (ˏ) {
            requestLayout();
        }
        return true;
    }

    protected LayoutParams ˏ() {
        return new LayoutParams(-1, -1);
    }

    public LayoutParams ˋ(AttributeSet attributeSet) {
        return new LayoutParams(getContext(), attributeSet);
    }

    protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
        return new LayoutParams(layoutParams);
    }

    protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof LayoutParams;
    }

    protected void onMeasure(int i, int i2) {
        Object obj;
        int i3;
        ॱ();
        measureChildWithMargins(this.ˏ, i, 0, i2, 0);
        LayoutParams layoutParams = (LayoutParams) this.ˏ.getLayoutParams();
        int max = Math.max(0, (this.ˏ.getMeasuredWidth() + layoutParams.leftMargin) + layoutParams.rightMargin);
        int max2 = Math.max(0, layoutParams.bottomMargin + (this.ˏ.getMeasuredHeight() + layoutParams.topMargin));
        int combineMeasuredStates = View.combineMeasuredStates(0, this.ˏ.getMeasuredState());
        if ((ViewCompat.ʻॱ(this) & 256) != 0) {
            obj = 1;
        } else {
            obj = null;
        }
        if (obj != null) {
            i3 = this.ॱॱ;
            if (this.ˏॱ && this.ˏ.ˏ() != null) {
                i3 += this.ॱॱ;
            }
        } else {
            i3 = this.ˏ.getVisibility() != 8 ? this.ˏ.getMeasuredHeight() : 0;
        }
        this.ॱˎ.set(this.ᐝॱ);
        this.ˈ.set(this.ॱᐝ);
        Rect rect;
        Rect rect2;
        if (this.ॱˊ || obj != null) {
            rect = this.ˈ;
            rect.top = i3 + rect.top;
            rect2 = this.ˈ;
            rect2.bottom += 0;
        } else {
            rect = this.ॱˎ;
            rect.top = i3 + rect.top;
            rect2 = this.ॱˎ;
            rect2.bottom += 0;
        }
        ˏ(this.ᐝ, this.ॱˎ, true, true, true, true);
        if (!this.ʾ.equals(this.ˈ)) {
            this.ʾ.set(this.ˈ);
            this.ᐝ.ॱ(this.ˈ);
        }
        measureChildWithMargins(this.ᐝ, i, 0, i2, 0);
        layoutParams = (LayoutParams) this.ᐝ.getLayoutParams();
        int max3 = Math.max(max, (this.ᐝ.getMeasuredWidth() + layoutParams.leftMargin) + layoutParams.rightMargin);
        i3 = Math.max(max2, layoutParams.bottomMargin + (this.ᐝ.getMeasuredHeight() + layoutParams.topMargin));
        int combineMeasuredStates2 = View.combineMeasuredStates(combineMeasuredStates, this.ᐝ.getMeasuredState());
        setMeasuredDimension(View.resolveSizeAndState(Math.max(max3 + (getPaddingLeft() + getPaddingRight()), getSuggestedMinimumWidth()), i, combineMeasuredStates2), View.resolveSizeAndState(Math.max(i3 + (getPaddingTop() + getPaddingBottom()), getSuggestedMinimumHeight()), i2, combineMeasuredStates2 << 16));
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int childCount = getChildCount();
        int paddingLeft = getPaddingLeft();
        int paddingRight = (i3 - i) - getPaddingRight();
        int paddingTop = getPaddingTop();
        paddingRight = (i4 - i2) - getPaddingBottom();
        for (int i5 = 0; i5 < childCount; i5++) {
            View childAt = getChildAt(i5);
            if (childAt.getVisibility() != 8) {
                LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                int i6 = layoutParams.leftMargin + paddingLeft;
                paddingRight = layoutParams.topMargin + paddingTop;
                childAt.layout(i6, paddingRight, childAt.getMeasuredWidth() + i6, childAt.getMeasuredHeight() + paddingRight);
            }
        }
    }

    public void draw(Canvas canvas) {
        super.draw(canvas);
        if (this.ʼ != null && !this.ˋॱ) {
            int bottom = this.ˏ.getVisibility() == 0 ? (int) ((((float) this.ˏ.getBottom()) + this.ˏ.getTranslationY()) + 0.5f) : 0;
            this.ʼ.setBounds(0, bottom, getWidth(), this.ʼ.getIntrinsicHeight() + bottom);
            this.ʼ.draw(canvas);
        }
    }

    public boolean shouldDelayChildPressedState() {
        return false;
    }

    public boolean onStartNestedScroll(View view, View view2, int i) {
        if ((i & 2) == 0 || this.ˏ.getVisibility() != 0) {
            return false;
        }
        return this.ˊॱ;
    }

    public void onNestedScrollAccepted(View view, View view2, int i) {
        this.ˋˊ.ˎ(view, view2, i);
        this.ͺ = ˊ();
        ˋ();
        if (this.ʿ != null) {
            this.ʿ.ॱˊ();
        }
    }

    public void onNestedScroll(View view, int i, int i2, int i3, int i4) {
        this.ͺ += i2;
        setActionBarHideOffset(this.ͺ);
    }

    public void onStopNestedScroll(View view) {
        if (this.ˊॱ && !this.ˊ) {
            if (this.ͺ <= this.ˏ.getHeight()) {
                ͺ();
            } else {
                ˊॱ();
            }
        }
        if (this.ʿ != null) {
            this.ʿ.ˋॱ();
        }
    }

    public boolean onNestedFling(View view, float f, float f2, boolean z) {
        if (!this.ˊॱ || !z) {
            return false;
        }
        if (ˎ(f, f2)) {
            ˋॱ();
        } else {
            ˏॱ();
        }
        this.ˊ = true;
        return true;
    }

    public void onNestedPreScroll(View view, int i, int i2, int[] iArr) {
    }

    public boolean onNestedPreFling(View view, float f, float f2) {
        return false;
    }

    public int getNestedScrollAxes() {
        return this.ˋˊ.ॱ();
    }

    void ॱ() {
        if (this.ᐝ == null) {
            this.ᐝ = (ContentFrameLayout) findViewById(ah$i.ˊ);
            this.ˏ = (ActionBarContainer) findViewById(ah$i.ॱ);
            this.ʻ = ˎ(findViewById(ah$i.ˋ));
        }
    }

    private ck ˎ(View view) {
        if (view instanceof ck) {
            return (ck) view;
        }
        if (view instanceof Toolbar) {
            return ((Toolbar) view).ˋˊ();
        }
        throw new IllegalStateException("Can't make a decor toolbar out of " + view.getClass().getSimpleName());
    }

    public void setHideOnContentScrollEnabled(boolean z) {
        if (z != this.ˊॱ) {
            this.ˊॱ = z;
            if (!z) {
                ˋ();
                setActionBarHideOffset(0);
            }
        }
    }

    public int ˊ() {
        return this.ˏ != null ? -((int) this.ˏ.getTranslationY()) : 0;
    }

    public void setActionBarHideOffset(int i) {
        ˋ();
        this.ˏ.setTranslationY((float) (-Math.max(0, Math.min(i, this.ˏ.getHeight()))));
    }

    void ˋ() {
        removeCallbacks(this.ˊᐝ);
        removeCallbacks(this.ˊˋ);
        if (this.ॱ != null) {
            this.ॱ.cancel();
        }
    }

    private void ͺ() {
        ˋ();
        postDelayed(this.ˊᐝ, 600);
    }

    private void ˊॱ() {
        ˋ();
        postDelayed(this.ˊˋ, 600);
    }

    private void ˏॱ() {
        ˋ();
        this.ˊᐝ.run();
    }

    private void ˋॱ() {
        ˋ();
        this.ˊˋ.run();
    }

    private boolean ˎ(float f, float f2) {
        this.ʼॱ.fling(0, 0, 0, (int) f2, 0, 0, Integer.MIN_VALUE, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        if (this.ʼॱ.getFinalY() > this.ˏ.getHeight()) {
            return true;
        }
        return false;
    }

    public void setWindowCallback(Callback callback) {
        ॱ();
        this.ʻ.ˎ(callback);
    }

    public void setWindowTitle(CharSequence charSequence) {
        ॱ();
        this.ʻ.ˋ(charSequence);
    }

    public void ˏ(int i) {
        ॱ();
        switch (i) {
            case 2:
                this.ʻ.ˋ();
                return;
            case 5:
                this.ʻ.ʼ();
                return;
            case 109:
                setOverlayMode(true);
                return;
            default:
                return;
        }
    }

    public void setUiOptions(int i) {
    }

    public void setIcon(int i) {
        ॱ();
        this.ʻ.ˊ(i);
    }

    public void setIcon(Drawable drawable) {
        ॱ();
        this.ʻ.ˋ(drawable);
    }

    public void setLogo(int i) {
        ॱ();
        this.ʻ.ˏ(i);
    }

    public boolean ʻ() {
        ॱ();
        return this.ʻ.ᐝ();
    }

    public boolean ᐝ() {
        ॱ();
        return this.ʻ.ॱॱ();
    }

    public boolean ॱॱ() {
        ॱ();
        return this.ʻ.ʽ();
    }

    public boolean ʼ() {
        ॱ();
        return this.ʻ.ʻ();
    }

    public boolean ʽ() {
        ॱ();
        return this.ʻ.ˊॱ();
    }

    public void setMenuPrepared() {
        ॱ();
        this.ʻ.ͺ();
    }

    public void setMenu(Menu menu, bn.d dVar) {
        ॱ();
        this.ʻ.ॱ(menu, dVar);
    }

    public void ॱˊ() {
        ॱ();
        this.ʻ.ˏॱ();
    }
}
